package org.dbwebx.flex.control.chevron
{

	import flash.display.DisplayObject;
	import org.dbwebx.flex.control.menu.BaseMenuGenerator;
	import org.dbwebx.flex.control.menu.IMenuGenerator;

	public class MenuBasedChevronHandler implements IChevronHanlder
	{
		
		public function MenuBasedChevronHandler()
		{
			menuGenerator = new BaseMenuGenerator();
		}
		
		[Bindable]
		private var _dataObject:Object;
		
		[Bindable]
		private var _menuProvider:Array;
		
		private var _parent:DisplayObject;
		
		private var menuGenerator:IMenuGenerator;
		
		public function get dataObject():Object
		{
			return _dataObject;
		}
		
		public function set dataObject(value:Object):void
		{
			_dataObject = value;
		}
		
		public function handleClick():void
		{
			menuGenerator.setupMenuData(_dataObject, _menuProvider, _parent);
			menuGenerator.prepareMenu();
			menuGenerator.showMenu();
		}
		
		public function get menuProvider():Array
		{
			return _menuProvider;
		}
		
		public function set menuProvider(values:Array):void
		{
			_menuProvider = values;
		}
		
		public function get parent():DisplayObject
		{
			return _parent;
		}
		
		public function set parent(value:DisplayObject):void
		{
			_parent = value;
		}

	}
}